home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_gen / cfilesys.zip / FILESYS.H < prev    next >
C/C++ Source or Header  |  1994-06-19  |  6KB  |  161 lines

  1.  
  2. //***************************************************************************
  3. //
  4. // Class:                    CFileSystem
  5. //
  6. // Purpose:                To encapsulate access to the file system.
  7. //
  8. // Copyright:            Copyright 1993, 1994 Scott P. Leslie, All Rights Reserved.
  9. //
  10. // Version:                Version 1.1 for MS Windows 3.1 and MSVC 1.0.
  11. //
  12. // Important:            Read the README.TXT file included with this distribution
  13. //                                before using this class.
  14. //
  15. // Shareware:            This class is ShareWare.  If you use it, you should register
  16. //                                it with the author.  If you do not register it after 14 days
  17. //                                of use, you must discontinue using it.
  18. //
  19. //                                Contact the author at ScotLeslie@aol.com for more info.
  20. //
  21. // Distribution:    You may distribute this class unmodified as long as all
  22. //                                accompanying documentation and notes are also distributed.
  23. //                                Object code generated from this class (or any derivation
  24. //                                of this class) can only be distributed by registered users.
  25. //
  26. // Disclaimer:        This class is provided as is with no implied or express
  27. //                                warranties.  You should test this class for your particular
  28. //                                use on non-critical data before using it in a production
  29. //                                system.
  30. //
  31. //***************************************************************************
  32.  
  33. #ifndef _CFileSystem_h_
  34. #define _CFileSystem_h_
  35.  
  36.  
  37. #include "dos.h"
  38. #include "direct.h"
  39.  
  40. #include "stdafx.h"
  41.  
  42.  
  43. //***************************************************************************
  44. // Definitions
  45. //***************************************************************************
  46. #define DRIVE_UNDETERMINED 0
  47.  
  48.  
  49. //***************************************************************************
  50. // Enable backward compatibility mode if your code that used version 1.0
  51. // of CFileSystem does not compile with the new version.  Two functions
  52. // and a member variable were declared protected (instead of public) after
  53. // version 1.0.  You should change your code to work without
  54. // BACKWARD_COMPATIBLE defined since future versions of CFileSystem may not
  55. // support the BACKWARD_COMPATIBLE flag.
  56. //
  57. // To enable backward compatibility, delete the two slashes before the
  58. // #define below.
  59. //***************************************************************************
  60.  
  61. //#define BACKWARD_COMPATIBLE
  62.  
  63.  
  64. class CFileSystem : public CObject
  65. {
  66. public:
  67.     CFileSystem();                // Constructor
  68.     ~CFileSystem();                // Destructor
  69.  
  70.     // File/Directory Attributes
  71.  
  72.     enum Attribute {
  73.         normal        = CFile::normal,            // Normal Files
  74.         readOnly    = CFile::readOnly,        // Read-Only Files
  75.         hidden        = CFile::hidden,            // Hidden Files
  76.         system        = CFile::system,            // System Files
  77.         volume        = CFile::volume,            // Volume Label
  78.         directory    = CFile::directory,        // Subdirectory Entry
  79.         archive        = CFile::archive,            // Archive File
  80.  
  81.         allfiles    = CFile::normal        |        // All "files"
  82.                                 CFile::readOnly    |        // Used to determine "size" of directory.
  83.                                 CFile::hidden        |
  84.                                 CFile::system        |
  85.                                 CFile::archive,
  86.     }; // Attribute
  87.  
  88.  
  89.     // Directory Functions
  90.  
  91.     CString                GetCurrentDirectory();
  92.     BOOL                    ChangeDirectory(const CString& NewDirectory);
  93.     BOOL                    MakeDirectory(const CString& NewDirectory);
  94.     BOOL                    MakePath(const CString& NewDirectory);
  95.     BOOL                    DeleteDirectory(const CString& Directory, const BOOL bDeleteFilesAndDirs = FALSE);
  96.  
  97.     LONG                    GetDirectorySize(const CString& Directory = "", const CString& WildCard = "*.*", const BOOL bRecurseSubdirs = FALSE);
  98.  
  99.     // FileSystem Functions
  100.  
  101.     CString                GetCurrentFileSystem();
  102.     BOOL                    ChangeFileSystem(const CString& FileSystem);
  103.     CStringList *    GetFileSystemList();
  104.     CString                GetVolumeLabel(const CString& FileSystem);
  105.     LONG                    GetFileSystemType(const CString& FileSystem);
  106.  
  107.     // File Functions
  108.  
  109.     BOOL                    RenameFile(const CString& OldFileName, const CString& NewFileName);
  110.     BOOL                    DeleteFile(const CString& FileName);
  111.     BOOL                    DeleteFiles(const CString& FileSpec);
  112.  
  113.     BOOL                    CopyFile(const CString& SourceFileName, const CString& DestFileName, const unsigned long lBuffSize = 10240);
  114.     BOOL                    CopyFiles(const CString& FileSpec, const CString& DestPath);
  115.     BOOL                    CompareFiles(const CString& FileName1, const CString& FileName2, const unsigned long lBuffSize = 10240);
  116.  
  117.     // File/Path Name Functions
  118.  
  119.     CString                GetFileName(const CString& PathAndFileName);
  120.     CString                GetPath(const CString& PathAndFileName);
  121.  
  122.     // Directory Listing Functions
  123.  
  124.     CStringList    *    GetDirectory(const CString& SearchString, const Attribute eFileAttrib, const BOOL bRecurseSubDirs=FALSE, CStringList *pStringList = NULL);
  125.  
  126.     CStringList *    GetSubdirList(const CString& SearchDir, const BOOL bPathInName = TRUE);
  127.     CStringList *    GetFileList(const CString& SearchString, const Attribute eFileAttrib);
  128.  
  129.     CString *            GetDirectoryEntry(const CString& Wildcard = "", const Attribute eFileAttrib = normal);
  130.  
  131.  
  132.     // MFC StringList Functions
  133.  
  134.     static void        Sort(CStringList *pStringList);
  135.  
  136.     // MFC GUI Functions
  137.  
  138.     static void        LoadListBox(CListBox *pListBox, const CStringList * pStringList);
  139.     static void        LoadComboBox(CComboBox *pComboBox, const CStringList * pStringList);
  140.  
  141.  
  142. #ifndef BACKWARD_COMPATIBLE
  143. protected:
  144. #endif // BACKWARD_COMPATIBLE
  145.     BOOL                    ChangeFileSystem(const char cFileSystem);
  146.     BOOL                    CloseFile(CFile *pFile) const;
  147.  
  148.     int                        MaxFileNameLength;
  149.  
  150.  
  151. protected:
  152.     CString                AppendWildcard(const CString& Path, const CString& Wildcard);
  153.  
  154. private:
  155.     struct _find_t    m_FileInfo;
  156.  
  157. }; // CFileSystem
  158.  
  159. #endif // _CFileSystem_h_
  160.  
  161.